const API = require('../../pages/api/index')
const { typeJson } = require('../../utils/typejson')
let prolist = wx.getStorageSync('prolist')==''?wx.getStorageSync('prolist'):JSON.parse(wx.getStorageSync('prolist'))


Page({

  /**
   * 页面的初始数据
   */
  data: {
    pulldown:"",
    pullup:2,
    addButton:false,
    prolist:wx.getStorageSync('prolist')==''?wx.getStorageSync('prolist'):JSON.parse(wx.getStorageSync('prolist')),
  time:null,
    listConfig: [
      {
        prop: "certificateName",
        label: "工种",
      },
      {
        prop: "validity",
        label: "操作证有效期"   
      },
      ],

      formConfig: [
        {
          prop: "certificateName",
          label: "工种",
        },
        {
          prop: "certificateType",
          label: "工种类型",
          type: "dropDown",
          jsonType: typeJson.papers,
        },
        {
          prop: "issueOrgan",
          label: "颁发机关",
        },
        {
          prop: "issueDate",
          label: "颁发日期",
        },
          {
          prop: "validity",
          label: "操作证有效期"   
        },
        {
          prop: "reviewSituation",
          label: "复审情况",
        },
        {
          prop: "recheckDate",
          label: "复检时间",
        },
        {
          prop: "status",
          label: "是否到期",
        },
       


        ],
    
        
        net: {
       
            select: {
              url: `/app/info/getList`,
              method: 'get',
              data: {
                
              }
            },
            delete: {
              url: '',
              method: 'get',
              data: {
                
              }
            },
            insert: {
              url: '',
              method: 'post',
              data: {
              
               
              }
            },
            update: {
              url: '',
              method: 'post',
              data: {
  
              }
            }
  
          
        },
        showCom:true
      },

     
  

  /**
   * 生命周期函数--监听页面加载
   */
onLoad(){

  this.setData({
    net:{
      select: {
        url: `/app/info/getList`,
        method: 'get',
        data: {
          userId: this.data.prolist.userId,
          endValidity:this.time()
        }
    }}
  })
 
},

time(){
  var date = new Date();
  var Y = date.getFullYear() + '-'; 
  var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
  var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
  var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes());
  var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
  var time1 = Y + M + D
  return time1
},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
   
    this.setData({
      showCom: false
    });
    this.setData({
      showCom: true
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

 /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.setData({
      pullup: this.data.pullup + 1
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})